using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using DoAn_LyThuyet.HeThongXuLy;

namespace DoAn_LyThuyet.HeThongLuuTru
{
    class CapNhatTaiSanDAO
    {
        static public DataTable SelectTaiSanCapNhat()
        {
            string sql = "select p.TenPhong, cn.MaTaiSan, cn.TinhTrang, cn.CanBoCapNhat,  cn.NgayCapNhat from CapNhatTaiSan cn, Phong p where cn.MaPhong = p.MaPhong";

            DataTable dt = DataAccess.GetTable(sql);
            return dt;
        }
        static public DataTable SelectPhong_CN()
        {
            string sql = "select * from Phong";

            DataTable dt = DataAccess.GetTable(sql);
            return dt;
        }
        static public DataTable Select_TS_PB()
        {
            string sql = "select MaTaiSan, MaPhong from PhanBoTaiSan";

            DataTable dt = DataAccess.GetTable(sql);
            return dt;
        }
        public static bool Insert_CN(CapNhatTaiSanDTO cn)
        {
            try
            {
               
                string strngay = cn.NgayCapNhat.ToShortDateString();
                string sql = "insert into CapNhatTaiSan(MaPhong,MaTaiSan, TinhTrang,CanBoCapNhat, NgayCapNhat) values('" +
                    cn.MaPhong + "','" + cn.MaTaiSan + "','" + cn.TinhTrang + 
                    "', '"+ cn.CanBoCapNhat +"','" + strngay + "')";
                DataAccess.GetTable(sql);
                return true;
            }

            catch (Exception ex)
            {
                return false;
            }

        }
    }
}
